import axios from 'axios';

// 获取商品列表的函数
export const getGoodsList = async () => {
  try {
    const response = await axios.get('http://192.168.239.53:8082/goods');
    return response.data;  // 返回商品数据
  } catch (error) {
    console.error('Error fetching goods list:', error);
    throw error;  // 抛出错误，方便在调用时处理
  }
};


export const fetchGoodsDetail = async (goodsId) => {
  try {
    const response = await axios.get(`http://192.168.239.53:8082/goods/${goodsId}`);
    return response.data; // 确保返回后端数据
  } catch (error) {
    console.error(`Error fetching goods detail for ID ${goodsId}:`, error);
    throw error; // 抛出错误方便调用时处理
  }
};
